package com.sky.mapper;

import com.sky.dto.DishDTO;
import com.sky.entity.Dish;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    @Select("select count(1) from dish where category_id = #{id}")
    int selectCate(Long id);
//菜品分页查询
    int selectCount(Dish dish);
    List<Dish> select(@Param("dish") Dish dish, @Param("start") int start, @Param("end") int end);
    List<Dish> list(Dish dish);
    //菜品启停
    void update(DishDTO dishDTO);
//新增菜品
    @Insert("insert into dish (id, name, category_id, price, image, description, status, create_time, update_time, create_user, update_user) VALUES " +
            "(#{id},#{name},#{categoryId},#{price},#{image},#{description},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(DishDTO dishDTO);
    //根据名字查询菜品id
    @Select("select id from dish where name = #{name}")
    Long selectByName(String name);
//根据id查询菜品
    @Select("select * from dish where id = #{id}")
    DishDTO selectById(Long id);

//删除商品
    @Delete("delete from dish where id = #{x}")
    void deleDish(long x);
//根据分类查询商品
    @Select("select * from dish where category_id = #{categoryId}")
    List<DishDTO> selectByCategory(Long categoryId);
//查询数量
    Integer countByMap(Map map);
}
